# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Josip Ponjavic <josipponjavic at gmail dot com>
# Contributor: Xu Fasheng <fasheng.xu[AT]gmail.com>

pkgname=deepin-desktop-schemas
pkgver=6.0.2
pkgrel=1
pkgdesc='GSettings deepin desktop-wide schemas'
arch=('any')
url="https://github.com/linuxdeepin/deepin-desktop-schemas"
license=('GPL3')
depends=('dconf' 'deepin-gtk-theme' 'deepin-icon-theme' 'deepin-sound-theme')
makedepends=('python' 'go' 'golang-deepin-lib')
conflicts=('deepin-artwork-themes')
replaces=('deepin-artwork-themes')
groups=('deepin')
source=("$pkgname-$pkgver.tar.gz::https://github.com/linuxdeepin/deepin-desktop-schemas/archive/$pkgver.tar.gz")
sha512sums=('06ed959f328ee1dd2a6ba592ca6483b3767034f26e1642c51a2ce21b1557bc9e64db3fe0ac4e516ecc368d6fbb6b2294b670486eefec5c033d705c281b894131')

prepare() {
  export GOPATH="$srcdir/build:/usr/share/gocode"
  cd deepin-desktop-schemas-$pkgver
  # fix default background url
  sed -i "s#/usr/share/backgrounds/default_background.jpg#/usr/share/backgrounds/deepin/desktop.jpg#" \
    overrides/common/com.deepin.wrap.gnome.desktop.override schemas/com.deepin.dde.appearance.gschema.xml
  # fix network checker url
  sed -i "s#'http://detect.uniontech.com', 'http://detectportal.deepin.com'#'http://ping.archlinux.org/nm-check.txt'#" schemas/com.deepin.dde.network-utils.gschema.xml
  grep uniontech schemas/com.deepin.dde.network-utils.gschema.xml && exit 1 || :
}

build() {
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"

  cd deepin-desktop-schemas-$pkgver
  make ARCH=x86
}

check() {
  cd deepin-desktop-schemas-$pkgver
  make test
}

package() {
  cd deepin-desktop-schemas-$pkgver
  make DESTDIR="$pkgdir" install
}
